﻿<%@ Page Title="Manage Users" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ManageUsers.aspx.cs" Inherits="TravelAgency.AspNet.Admins.ManageUsers" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register assembly="Telerik.OpenAccess.Web" namespace="Telerik.OpenAccess" tagprefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
                Name="Telerik.Web.UI.Common.Core.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI"
                Name="Telerik.Web.UI.Common.jQuery.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI"
                Name="Telerik.Web.UI.Common.jQueryInclude.js">
            </asp:ScriptReference>
        </Scripts>
    </telerik:RadScriptManager>
        

    <asp:Panel ID="PanelUsers" runat="server">

        <div class="top-padding">
            <h2>List of registered users</h2>
            <asp:Label ID="LabelSearch" runat="server" CssClass="search">
                                            
                <asp:LinkButton ID="LinkButtonSearch" runat="server" CssClass="button-search" Text="Search" onclick="LinkButtonSearch_Click"></asp:LinkButton>
                &nbsp;
                <asp:TextBox ID="TextBoxSearch" runat="server" Width="120px" Height="18px" Visible="true"></asp:TextBox>                                
            </asp:Label>
        </div>

        <telerik:RadListView ID="RadListViewUsers" runat="server"
            AllowPaging="True" 
            DataSourceID="OpenAccessDataSourceUsers"
            ItemPlaceholderID="PlaceHolderTrips" DataKeyNames="UserId,UserName" 
            onitemcreated="RadListViewUsers_ItemCreated" 
            onitemcommand="RadListViewUsers_ItemCommand">
            <LayoutTemplate>
                <div class="reservations">
                    <asp:Panel ID="TripPanel" CssClass="text-left" runat="server">
                    
                        <div class="divider"></div>
                        <asp:PlaceHolder ID="PlaceHolderTrips" runat="server"></asp:PlaceHolder>

                        <div class="pager">
                            <telerik:RadDataPager ID="RadDataPager1" runat="server"
                                PageSize="10" Font-Italic="True" BackColor="#FFE9C9" BorderColor="#FFE9C9" BorderStyle="None">
                                <Fields>
                                    <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                    <telerik:RadDataPagerGoToPageField CurrentPageText="Page" />
                                </Fields>
                            </telerik:RadDataPager>
                        </div>
                               
                    </asp:Panel>
                </div>
            </LayoutTemplate>

            <ItemTemplate>
                <div class="reservation">
                    <b>User name:</b> 
                    <asp:Label ID="Label1" runat="server" Text='<%# UserNameWordWrapEval("UserName") %>'></asp:Label>;
                    <b>User role:</b> 
                    <asp:Label ID="Label2" runat="server" Text='<%# GetFirstRoleOfUser("UserName") %>'></asp:Label>;
                    <asp:LinkButton ID="LinkButtonEdit" runat="server" Text="Edit" CommandName="Edit"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButtonDelete" runat="server" Text="Delete" CommandName="Select"></asp:LinkButton>
                </div>
            </ItemTemplate>

            <SelectedItemTemplate>
                <div class="reservation-selected">
                    <b>User name: </b>
                    <asp:Label ID="Label4" runat="server" Text='<%# UserNameWordWrapEval("UserName") %>'></asp:Label>;
                    &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label2" runat="server" CssClass="prompt">Are you sure you want to delete the user and its reservations?</asp:Label>
                    <asp:LinkButton runat="server" ID="LinkButtonYas" Text="Yes" OnClick="LinkButtonYas_Click"></asp:LinkButton> /
                    <asp:LinkButton runat="server" ID="LinkButtonNo" Text="No" CommandName="Deselect"></asp:LinkButton>
                </div>
            </SelectedItemTemplate>

            <EditItemTemplate>
                <div class="reservation-selected">
                    <b>User name:</b> 
                    <asp:Label ID="Label5" runat="server" Text='<%# UserNameWordWrapEval("UserName") %>'></asp:Label>;
                    <b>User role:</b> 
                    <asp:Label ID="Label6" runat="server" Text='<%# GetFirstRoleOfUser("UserName") %>'></asp:Label>;
                    &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="LabelNoEditAction" runat="server" Text="No edit action" Visible="false"></asp:Label>
                    <asp:LinkButton ID="LinkButtonGrandRole" runat="server" Text="Grand Role Agent" Visible="false"
                        OnClick="GrandRoleAgent_Click"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButtonSuspendRole" runat="server" Text="Suspend Role Agent" Visible="false"
                        OnClick="SuspendRoleAgentGrandRoleCustomer_Click"></asp:LinkButton> /
                    <asp:LinkButton ID="LinkButtonCancelBack" runat="server" CommandName="Cancel"></asp:LinkButton>
                </div>
            </EditItemTemplate>

            <EmptyDataTemplate>
                    
                            <asp:Panel ID="PanelTrip" runat="server" CssClass="navigation-header">                     
                                <asp:Panel runat="server" ID="PanelTripDetails">

                                    <h2>No users</h2>

                                </asp:Panel>        
                            </asp:Panel>
                    
            </EmptyDataTemplate>

        </telerik:RadListView>
    

    </asp:Panel>

    <telerik:OpenAccessDataSource ID="OpenAccessDataSourceUsers" runat="server" 
        ObjectContextProvider="TravelAgency.DAL.TravelAgencyEntities, TravelAgency.DAL" 
        TypeName="TravelAgency.DAL.Aspnet_User" Where="UserId&lt;&gt;@userId">
        <WhereParameters>
            <asp:SessionParameter DbType="Guid" Name="userId" SessionField="userId" />
        </WhereParameters>
    </telerik:OpenAccessDataSource>
    
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="TripPanel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelUsers" LoadingPanelID="RadAjaxLoadingPanel1"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="LinkButtonSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelUsers" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Black">
    </telerik:RadAjaxLoadingPanel>

</asp:Content>
